package net.aiion.weave.impl.bytecode.events;

import net.aiion.weave.spi.bytecode.BytecodeVisitor;
import net.aiion.weave.spi.bytecode.events.MethodStartBytecodeEvent;

public class MethodStartBytecodeEventImpl extends BytecodeEventImpl implements MethodStartBytecodeEvent
{
    private int modifiers;
    private String name;
    private String descriptor;
    private String signature;
    private String[] exceptionNames;

    public MethodStartBytecodeEventImpl(final int aModifiers, final String aName, final String aDescriptor,
        final String aSignature, final String[] aExceptionNames)
    {
        modifiers = aModifiers;
        name = aName;
        descriptor = aDescriptor;
        signature = aSignature;
        exceptionNames = aExceptionNames;
    }

    @Override
    public int getType() {
        return METHOD_START;
    }

    @Override
    public void setModifiers(final int aModifiers) {
        modifiers = aModifiers;
    }

    @Override
    public int getModifiers() {
        return modifiers;
    }

    @Override
    public void setName(final String aName) {
        name = aName;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public boolean isConstructor() {
        return "<init>".equals(name);
    }

    @Override
    public boolean isStaticConstructor() {
        return "<clinit>".equals(name);
    }

    @Override
    public void setDescriptor(final String aDescriptor) {
        descriptor = aDescriptor;
    }

    @Override
    public String getDescriptor() {
        return descriptor;
    }

    @Override
    public void setSignature(final String aSignature) {
        signature = aSignature;
    }

    @Override
    public String getSignature() {
        return signature;
    }

    @Override
    public void setExceptionNames(final String[] aExceptionNames) {
        exceptionNames = aExceptionNames;
    }

    @Override
    public String[] getExceptionNames() {
        return exceptionNames;
    }

    @Override
    public BytecodeVisitor acceptBytecodeVisitor(final BytecodeVisitor aBytecodeVisitor) {
        return aBytecodeVisitor.asBytecodeClassVisitor().visitMethodStart(this);
    }
}
